package com.jsbb.util.digest;

import java.security.MessageDigest;

/**
 * MD5加密
 *
 * @author w
 * @date 2021-03-05
 */
public class Md5Utils {

    public static String encrypt(String data) {
        StringBuilder sb = new StringBuilder();
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] array = md.digest(data.getBytes("UTF-8"));
            for (byte item : array) {
                sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return sb.toString();
    }
}
